<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{js/jquery-3.6.0.min.js}"></script>
    <style th:src="@{css/bootstrap.min.css}" rel="stylesheet"></style>
</head>
<body>
<h2>上传文件示例</h2>
<div th:if="${uploadStatus}" style="color: red" th:text="${uploadStatus}">上传结果</div>
<form th:action="@{/upfile}" method="post" enctype="multipart/form-data">
    上传文件:<input type="button" value="添加文件" onclick="add()">
    <div usageId="file" style="margin-top: 10px" th:value="上传文件列表"></div>
    <input usageId="submit" type="submit" value="上传" style="display: none;margin-top: 10px;" />
</form>
<script>
    function add(){
        var iner="<div>";
        iner+="<input type='file' name='fileload' required='required'>";
        iner+="</div>";
        $("#file").append(iner);
        $("#submit").css('display','block');
    }

</script>
</body>
</html>